#ifndef __UIDFACTORY_H__
#define __UIDFACTORY_H__
/**
 * @file UIDFactory.h
 * @author Lost
 * @date 2020/04/19
 * @brief UID工厂类
 * 
 */
#include "Singleton.h"

#include <stdint.h>

#define  TOTAL_BIT 64

#define BIT_SERVER 16
#define OFFSET_SERVER ((TOTAL_BIT)-(BIT_SERVER))

#define BIT_TYPE 8
#define OFFSET_TYPE ((TOTAL_BIT)-(BIT_SERVER)-(BIT_TYPE))

#define BIT_TIMESTAMP 32 
#define OFFSET_TIMESTAMP ((TOTAL_BIT)-(BIT_SERVER)-(BIT_TYPE)-(BIT_TIMESTAMP))

#define BIT_INDEX 8
#define OFFSET_INDEX ((TOTAL_BIT)-(BIT_SERVER)-(BIT_TYPE)-(BIT_TIMESTAMP)-(BIT_INDEX))


#define INDEX_MAX 256
//#define 

/**
 * @brief UID类型
 * @note 
 */
enum EnmUIDType
{
    /*!< 错误类型 */
    ENM_UID_TYPE_ERROR = 0,
    /*!< 帐号类型 */
    ENM_UID_TYPE_ACC = 1,
    /*!< 角色类型 */
    ENM_UID_TYPE_ROLE = 2,
    /*!< 最大枚举 */
    ENM_UID_TYPE_MAX,
};



/**
 * @brief 生成UID工厂类
 * @note 
 */
class CUIDFactory : public CSingleton<CUIDFactory>
{
public:
    CUIDFactory();
    ~CUIDFactory();
public:
    /**
     * @brief 初始化
     * @note 
     */
    bool Init( int iServerID = 0 );

    /**
     * @brief 创建唯一标识
     * @note 
     */
    uint64_t CreateUID(EnmUIDType enmType);

private:
    /*!< 服务器id */
    int m_iServerID;
};



#endif //__UIDFACTORY_H__